/*
 *      fcompare.cpp
 *      
 *      Copyright 2008 Charlotte Curtis <c.f.curtis@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


#include <iostream>
#include <fstream>
#include <marsyas/realvec.h>
#include <marsyas/NumericLib.h>

using namespace std;
using namespace Marsyas;


int main(int argc, char** argv)
{
	if (argc < 3) {
		cout << "Usage: " << argv[0] << "vec1 vec2" << endl;
		cout << "calculates the distance between two song feature vectors" << endl;
		return 1;
	}
	realvec v1;
	realvec v2;
	
	// empty vector for euclidean distance
	realvec cov;
	mrs_real res;
	
	// read in the vectors
	try {
		v1.read(argv[1]);
		v2.read(argv[2]);
	} catch (int i)
	{
		cout << "Error reading vectors" << endl;
		return 1;
	}
	
	// calculate the result
	try {
		res = NumericLib::euclideanDistance(v1, v2, cov);
	} catch (int i)
	{
		cout << "Error computing distance" << endl;
		return 1;
	}

	cout.setf(ios_base::fixed, ios_base::floatfield);
    cout.precision(12);
	
	cout << right << res << endl;
	return 0;
}
